package br.org.credfaz.sis.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import br.org.credfaz.sis.MysqlConnectionFactory;
import br.org.credfaz.sis.modelo.LancamentoCca;

public class LancamentoCcaDAO {

	private final Connection connection;
	
	public LancamentoCcaDAO(){
		try{
			connection = new MysqlConnectionFactory().getConnection();
		}catch (SQLException e){
			throw new RuntimeException(e);
		}
	}
	
	public void adiciona(LancamentoCca lancca){
		String sql = "insert into lancamentocca (datalote, numseqlanc, numlotelanc, nummatricula, idtipohistoricolanc," +
				"datahorainclusao, valorlanc )values (?, ?, ?, ?, ?, ?, ?)";
		
		
		PreparedStatement stmt;
		try{
			stmt = connection.prepareStatement(sql);
			

			stmt.setDate(1, lancca.getDatalote());
			stmt.setInt(2, lancca.getNumseqlanc());
			stmt.setInt(3, lancca.getNumlotelanc());
			stmt.setInt(4, lancca.getNummatricula());
			stmt.setInt(5, lancca.getIdtipohistoricolanc());
			stmt.setDate(6, lancca.getDatahorainclusao());
			stmt.setDouble(7, lancca.getValorlanc());
			
			
			stmt.execute();
			
		}catch (SQLException e){
			throw new RuntimeException(e);
		}
	}

}
